﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AdmBase;
using Guedes_Library;

public partial class admin_pages_banner_Default : TelaBase
{
    private BannerBusiness bBusiness;

    public BannerBusiness BBusiness
    {
        get
        {
            if (bBusiness == null)
                bBusiness = new BannerBusiness();
            return bBusiness;
        }
        set { bBusiness = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        IsLogado();
    }

    protected void SelectGrid(object sender, EventArgs e)
    {
        GridView grid = (GridView)sender;
        Response.Redirect("~/admin/pages/banner/Novo.aspx?id=" + grid.SelectedValue.ToString());
    }

    protected void Deletar(object sender, EventArgs e)
    {
        int id = int.Parse(((LinkButton)sender).CommandName);

        string msg = "";

        if (msg == "")
        {
            banner p = BBusiness.GetById(id);
            string url = p.Img_Banner;
            msg = BBusiness.Deletar(id);
            if (msg != "")
                ApagarArquivo(url);
        }
        DataBind();
        GridViewBanner.DataBind();
        ShowMensagem("Atenção", msg);
    }
}